package com.huage_09.lesson_03;

import java.util.function.Supplier;

public class SupplierDemo {
    public static void main(String[] args) {
        int[] arr = {23,78,56,43};
        int max1 = getMax(() -> {
            int max = arr[0];
            for (int i = 1; i < arr.length; i++) {
                if (max < arr[i]) {
                    max = arr[i];
                }
            }
            return max;
        });

        System.out.println("max = " + max1);

    }
    private static int getMax(Supplier<Integer> sup){
        return sup.get();
    }
}
